package com.mgface.zookeeper.curator;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.data.Stat;

public class UpdateNode {

	public static void main(String[] args) throws Exception {
		CuratorFramework client = CuratorFrameworkFactory.builder().connectString("127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183")
				.sessionTimeoutMs(10_000)
				//.namespace("curator")//指定隔离命名空间
				.retryPolicy(new ExponentialBackoffRetry(100, 3))//baseSleepTimeMs：初始sleep时间
				.build();
		client.start();
		System.out.println("启动完毕...");
		Stat st = new Stat();
		System.out.println("获取数据:"+client.getData().storingStatIn(st).forPath("/mgface"));
		System.out.println(st);
		Stat stat = client.setData().withVersion(st.getVersion()).forPath("/mgface","mgface".getBytes());
		System.out.println(stat);

	}

}
